home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part2 / 15749 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.6 KB

  1. Path: lrz-muenchen.de!news
  2. From: watzka@stat.uni-muenchen.de (Kurt Watzka)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: PUBLIC / PRIVATE
  5. Date: 21 Apr 1996 16:32:54 GMT
  6. Organization: Leibniz-Rechenzentrum, Muenchen (Germany)
  7. Distribution: world
  8. Message-ID: <4ldnvm$bui@sparcserver.lrz-muenchen.de>
  9. References: <317941B9.39B7@umdnj.edu>
  10. NNTP-Posting-Host: sun2.lrz-muenchen.de
  11.  
  12. "G Ralph Kuntz, MD" <kuntz@umdnj.edu> writes:
  13.  
  14. >> Perhaps in a header file or somewhere you'll find something like
  15. >> 
  16. >>         #define PUBLIC
  17. >>         #define PRIVATE static
  18.  
  19. >A couple of books I have on the C programming style suggests staying 
  20. >away from this sort of thing for excatly this reason.  In particular, 
  21. >they suggest NOT defining FALSE = 0 and TRUE = 1 but just using the 
  22. >constants 0 and 1 directly and testing variables as in "if (a_boolean) 
  23. >..." rather than "if (a_boolean == TRUE) ..."
  24.  
  25. Whether it is good practice to define or not define TRUE and FALSE,
  26. as long as TRUE is defined as a non-zero value and false is defined as
  27. zero is open to debate. The main problem with this is that everybody
  28. does it, but does it slightly different from all others in most 
  29. cases so that you end up with half a dozend different TRUE definitions
  30. in a project that includes 5 third party header files.
  31.  
  32. "if (a_boolean == TRUE)", otoh, is a _very_ strange piece of code.
  33. Why would you stop with _one_ level of truth? This should at least
  34. be "if (((a_boolean == TRUE) == TRUE) == TRUE)" for extra clarity.
  35.  
  36. Kurt
  37. -- 
  38. | Kurt Watzka                             Phone : +49-89-2180-6254
  39. | watzka@stat.uni-muenchen.de
  40.